function reallocObjectGroup(p,n)
  use derived
  implicit none

  type(GroupType),pointer,dimension(:) :: &
       reallocObjectGroup,p
  integer,intent(in) :: n
  integer :: i,j,nold,ierr

  allocate(reallocObjectGroup(1:n),stat=ierr)
  if (ierr.ne.0) call abnormal_stop("reallocObjectGroup",&
       "Memory allocation cause an error.")

  do i=1,n
     nullify(reallocObjectGroup(i)%point_type)
     nullify(reallocObjectGroup(i)%min_size)
     nullify(reallocObjectGroup(i)%max_size)
  end do

  if (.not.associated(p)) return

  nold=n-1
  do i=1,nold
     reallocObjectGroup(i)%index=p(i)%index
     reallocObjectGroup(i)%n_point=p(i)%n_point
     reallocObjectGroup(i)%group_type=p(i)%group_type
     reallocObjectGroup(i)%total_size=p(i)%total_size
     reallocObjectGroup(i)%single_type=p(i)%single_type
     allocate(reallocObjectGroup(i)%point_type(p(i)%n_point))
     allocate(reallocObjectGroup(i)%min_size(p(i)%n_point))
     allocate(reallocObjectGroup(i)%max_size(p(i)%n_point))
     do j=1,p(i)%n_point
        reallocObjectGroup(i)%point_type(j)=p(i)%point_type(j)
        reallocObjectGroup(i)%min_size(j)=p(i)%min_size(j)
        reallocObjectGroup(i)%max_size(j)=p(i)%max_size(j)
     end do
     deallocate(p(i)%point_type)
     deallocate(p(i)%min_size)
     deallocate(p(i)%max_size)
  end do

  deallocate(p)

  return

end function reallocObjectGroup
